package cn.ibobo.lease.common.enums;

import lombok.Getter;

/**
 * Description: 控制器返回值枚举类 <br />
 * Project: meirenhui <br />
 * ClassName: DeptMapper <br />
 * Copyright: Copyright (c) 2017 deshang<br />
 *
 * @author bushy
 * @version 1.0 2017年10月9日上午10:30:05
 */
@Getter
public enum ResultEnum {

    EXCEPTION(-1, "请求出现异常"),
    FAIL(0, "失败"),
    SUCCESS(1, "成功"),
    ERR_NAME_PSWD(2, "用户名或密码错误！"),
    ERR_PARAM_TYPE(3, "参数类型错误！"),
    NO_SUPPORT_EDIT(4, "暂不支持修改！"),
    NO_COUP(5, "无此点金券！"),
    COUP_LOSE_EFF(6, "此点金券已使用或已失效！"),
    COUP_NO_MATCH(7, "点金券和优惠金额不匹配！"),
    LEA_NO_EXIST(8, "租赁物品不存在！"),
    ERR_LEA_STATUS(9, "此物品暂时不可租赁！"),
    NO_ENOUGH_DEPOSIT(10, "押金不足！"),
    ERR_USE_STATUS(11, "租赁记录状态错误！"),
    NO_LEA_REC(12, "未查询到租赁记录！"),
    ACCOUNT_REPEAT(13, "此账号已经存在！"),
    CODE_REPEAT(14, "编号已经存在！"),
    RES_NO_EXIST(15, "租赁记录不存！"),
    NO_ENOUGH_COUPON(16, "点金券余额不足！"),
    LEVEL_TOO_LOW(17, "顾客等级不足！"),
    NO_ENOUGH_BALANCE(18, "充值金不足！"),
    HAS_GOT_COUPON(19, "您已领用过点金券！"),
    NO_COUPON(20, "点金券已被领完！"),
    NO_SMS_CODE(21, "验证码无效！"),
    ;
    private Integer code;

    private String msg;

    ResultEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * @Description 根据code获取名称
     * @Author lililiang
     * @Date 2018/10/18 19:42
     * @Param [index]
     * @Return java.lang.String
     */
    public static String getMsg(int index) {
        for (ResultEnum c : ResultEnum.values()) {
            if (c.getCode().equals(index)) {
                return c.msg;
            }
        }
        return null;
    }
}
